<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>grep</title>
</head>
<body>
	grep: function( elems, callback, inv ) {
		var retVal,
			ret = [],
			i = 0,
			length = elems.length;
		inv = !!inv;

		// Go through the array, only saving the items
		// that pass the validator function
		for ( ; i < length; i++ ) {
			retVal = !!callback( elems[ i ], i );
			if ( inv !== retVal ) {
				ret.push( elems[ i ] );
			}
		}

		return ret;
	}
</body>
</html>
<script src='jquery源码分析.js'></script>
<script>
//如果写了true，就会取相反的结果，有点像非的意思
	var arr = [1,2,3,4];
	var arr = $.grep(arr,function(n,i){
		return n > 2;
	}, true );
	console.log(arr);
</script>